import { getMsbdList, DelMsbdList, AddMsbdList, UpdateMsbdList } from "../api/msbd"


let state = {
    list: [],
    classify: []
}

let mutations = {
    SET_LIST(state, list) {
        state.list = list
    },
    SET_CLASSIFY(state, classify) {
        state.classify = classify
    }
}

let actions = {
    async GetList({ commit }) {
        let r = await getMsbdList();
        commit("SET_LIST", r.data.data)
        commit("SET_CLASSIFY", r.data.classify)
        console.log(r.data.classify)
    },
    async DelList({ }, id) {
        await DelMsbdList({ id })
    },
    async AddList({ }, form) {
        await AddMsbdList(form)
    },
    async UpdateList({ }, data) {
        await UpdateMsbdList({...data})
    }
}

let getters = {

}


let msbd = {
    namespaced: true,
    state,
    mutations,
    actions,
    getters
}


export default msbd